﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_ACCIDENT
    {
        private Guid m_AccidentID;
        private string m_AccidentName;
        private string m_Allowance;
        private string m_Damage;
        private DateTime m_DateOccured;
        private string m_Description;
        private string m_EmployeeCode;
        private string m_Injury;
        private string m_Location;
        private string m_Note;
        private string m_Reason;

        public HRM_PROCESS_ACCIDENT()
        {
            this.m_AccidentID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_AccidentName = "";
            this.m_Reason = "";
            this.m_DateOccured = DateTime.Now;
            this.m_Location = "";
            this.m_Description = "";
            this.m_Damage = "";
            this.m_Injury = "";
            this.m_Allowance = "";
            this.m_Note = "";
        }

        public HRM_PROCESS_ACCIDENT(Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            this.m_AccidentID = AccidentID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_AccidentName = AccidentName;
            this.m_Reason = Reason;
            this.m_DateOccured = DateOccured;
            this.m_Location = Location;
            this.m_Description = Description;
            this.m_Damage = Damage;
            this.m_Injury = Injury;
            this.m_Allowance = Allowance;
            this.m_Note = Note;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { this.m_AccidentID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Delete", myParams, myValues);
        }

        public string Delete(Guid AccidentID)
        {
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid AccidentID)
        {
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_ACCIDENT_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid AccidentID)
        {
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_ACCIDENT_Delete", myParams, myValues);
        }

        public string DeleteByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_DeleteByMonth", myParams, myValues);
        }

        public bool Exist(Guid AccidentID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_ACCIDENT_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid AccidentID)
        {
            string str = "";
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_ACCIDENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_AccidentID = reader.GetGuid(reader.GetOrdinal("AccidentID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AccidentName = Convert.ToString(reader["AccidentName"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DateOccured = Convert.ToDateTime(reader["DateOccured"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Damage = Convert.ToString(reader["Damage"]);
                    this.m_Injury = Convert.ToString(reader["Injury"]);
                    this.m_Allowance = Convert.ToString(reader["Allowance"]);
                    this.m_Note = Convert.ToString(reader["Note"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid AccidentID)
        {
            string str = "";
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_ACCIDENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_AccidentID = reader.GetGuid(reader.GetOrdinal("AccidentID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AccidentName = Convert.ToString(reader["AccidentName"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DateOccured = Convert.ToDateTime(reader["DateOccured"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Damage = Convert.ToString(reader["Damage"]);
                    this.m_Injury = Convert.ToString(reader["Injury"]);
                    this.m_Allowance = Convert.ToString(reader["Allowance"]);
                    this.m_Note = Convert.ToString(reader["Note"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid AccidentID)
        {
            string str = "";
            string[] myParams = new string[] { "@AccidentID" };
            object[] myValues = new object[] { AccidentID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_ACCIDENT_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_AccidentID = reader.GetGuid(reader.GetOrdinal("AccidentID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_AccidentName = Convert.ToString(reader["AccidentName"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DateOccured = Convert.ToDateTime(reader["DateOccured"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Damage = Convert.ToString(reader["Damage"]);
                    this.m_Injury = Convert.ToString(reader["Injury"]);
                    this.m_Allowance = Convert.ToString(reader["Allowance"]);
                    this.m_Note = Convert.ToString(reader["Note"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_ACCIDENT_GetListByMonth", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { this.m_AccidentID, this.m_EmployeeCode, this.m_AccidentName, this.m_Reason, this.m_DateOccured, this.m_Location, this.m_Description, this.m_Damage, this.m_Injury, this.m_Allowance, this.m_Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { this.m_AccidentID, this.m_EmployeeCode, this.m_AccidentName, this.m_Reason, this.m_DateOccured, this.m_Location, this.m_Description, this.m_Damage, this.m_Injury, this.m_Allowance, this.m_Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_ACCIDENT_Insert", myParams, myValues);
        }

        public string Insert(Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_ACCIDENT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_ACCIDENT_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_ACCIDENT", "JobCode", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { this.m_AccidentID, this.m_EmployeeCode, this.m_AccidentName, this.m_Reason, this.m_DateOccured, this.m_Location, this.m_Description, this.m_Damage, this.m_Injury, this.m_Allowance, this.m_Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Update", myParams, myValues);
        }

        public string Update(Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_ACCIDENT_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_ACCIDENT_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid AccidentID, string EmployeeCode, string AccidentName, string Reason, DateTime DateOccured, string Location, string Description, string Damage, string Injury, string Allowance, string Note)
        {
            string[] myParams = new string[] { "@AccidentID", "@EmployeeCode", "@AccidentName", "@Reason", "@DateOccured", "@Location", "@Description", "@Damage", "@Injury", "@Allowance", "@Note" };
            object[] myValues = new object[] { AccidentID, EmployeeCode, AccidentName, Reason, DateOccured, Location, Description, Damage, Injury, Allowance, Note };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_ACCIDENT_Update", myParams, myValues);
        }

        [DisplayName("AccidentID"), Category("Primary Key")]
        public Guid AccidentID
        {
            get
            {
                return this.m_AccidentID;
            }
            set
            {
                this.m_AccidentID = value;
            }
        }

        [Category("Column"), DisplayName("AccidentName")]
        public string AccidentName
        {
            get
            {
                return this.m_AccidentName;
            }
            set
            {
                this.m_AccidentName = value;
            }
        }

        [Category("Column"), DisplayName("Allowance")]
        public string Allowance
        {
            get
            {
                return this.m_Allowance;
            }
            set
            {
                this.m_Allowance = value;
            }
        }

        [DisplayName("Damage"), Category("Column")]
        public string Damage
        {
            get
            {
                return this.m_Damage;
            }
            set
            {
                this.m_Damage = value;
            }
        }

        [DisplayName("DateOccured"), Category("Column")]
        public DateTime DateOccured
        {
            get
            {
                return this.m_DateOccured;
            }
            set
            {
                this.m_DateOccured = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [Category("Column"), DisplayName("Injury")]
        public string Injury
        {
            get
            {
                return this.m_Injury;
            }
            set
            {
                this.m_Injury = value;
            }
        }

        [Category("Column"), DisplayName("Location")]
        public string Location
        {
            get
            {
                return this.m_Location;
            }
            set
            {
                this.m_Location = value;
            }
        }

        [DisplayName("Note"), Category("Column")]
        public string Note
        {
            get
            {
                return this.m_Note;
            }
            set
            {
                this.m_Note = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_ACCIDENT";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("Reason"), Category("Column")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }
    }
}

